<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body> 
   <table>
       <tr>
      	<td>用户名</td>
      	<td>地址</td>
      </tr>
	{foreach:items=$res}
     <tr>
     	<td>{$item['name']}</td>
     	<td>{$item['addr']} <input type="button" value="酒店" id="serch">
     	                    <input type="button" value="饭店" id="serch1">
                            <td> <div id="map" style="width:500px;height:200px;border:solid;"></div></td>
     	   </td>

     </tr>

	{/foreach}
	</table>
</body>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=fZAQ5GXps6eyzh88eCoOjH1kDUMwe06u"></script>
<script type="text/javascript" src="/public/js/jq.js"></script>
<script type="text/javascript">
	$("#serch").click(function(){
		  addr="{$item['addr']}";
	
       $.ajax({
       	url:"{url:/dayz1m/dtss}",
       	data:{addr:addr},
       	dataType:"json",
       	type:"post",
       	success:function(res){
       		// alert(res);
       		// console.log(res);
         var lng=res.lng;
          var lat=res.lat;
          // console.log(lng);
       var map = new BMap.Map("map");            // 创建Map实例
	var mPoint = new BMap.Point(lng,lat);  
	map.enableScrollWheelZoom();
	map.centerAndZoom(mPoint,15);

	var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
    map.addOverlay(circle);
    var local =  new BMap.LocalSearch(map, {renderOptions: {map: map, autoViewport: false}});  
    local.searchNearby('酒店',mPoint,3000);

       
       	}
       })


	})

	$("#serch1").click(function(){
		  addr="{$item['addr']}";
		 // if(addr!=''){

		 // }else{
		 // 	alert("不能为空");
		 // 	return false;
		 // }

       $.ajax({
       	url:"{url:/dayz1m/dtss}",
       	data:{addr:addr},
       	dataType:"json",
       	type:"post",
       	success:function(res){
       		// alert(res);
       		// console.log(res);
         var lng=res.lng;
          var lat=res.lat;
          // console.log(lng);
       var map = new BMap.Map("map");            // 创建Map实例
	var mPoint = new BMap.Point(lng,lat);  
	map.enableScrollWheelZoom();
	map.centerAndZoom(mPoint,15);

	var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
    map.addOverlay(circle);
    var local =  new BMap.LocalSearch(map, {renderOptions: {map: map, autoViewport: false}});  
    local.searchNearby('饭店',mPoint,3000);

       
       	}
       })


	})

	var map=new BMap.Map("map");
	var point = new BMap.Point(116.331398,39.897445);
	map.centerAndZoom(point,12);
	
</script>
</html>